﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Javavaj.iHunter;
using Javavaj.iHunter.Core;
namespace Javavaj.iHunter.Searching
{
    public class KeywordSearcher : ISearcher
    {
        private string keyword;
        public KeywordSearcher(string keyword)
        {
            this.keyword = keyword;
        }
        #region ISearcher 成员

        public bool Match(System.Data.DataRow row)
        {
            if (((string)row["Title"]).IndexOf(keyword, StringComparison.CurrentCultureIgnoreCase) != -1)
                return true;

            if (((string)row["Author"]).IndexOf(keyword, StringComparison.CurrentCultureIgnoreCase) != -1)
                return true;
            if (((string)row["Description"]).IndexOf(keyword, StringComparison.CurrentCultureIgnoreCase) != -1)
                return true;
            if (((string)row["Category"]).IndexOf(keyword, StringComparison.CurrentCultureIgnoreCase) != -1)
                return true;

            if (!((bool)row["ContentIsBinary"]) &&
                ((string)row["TextContent"]).IndexOf(keyword, StringComparison.CurrentCultureIgnoreCase) != -1
                )
            {
                return true;
            }

            return false;
        }

        #endregion
    }
}
